home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Proper way to add font m
- Sent: 6/24/96 5:18 PM
- Received: 6/24/96 5:51 PM
- From: Mary Boetcher, mary_boetcher@quickmail.apple.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Mail*LinkĀ® SMTP RE>Proper way to add font menu?
-
- Here is some code from my test part that creates and manages a font menu.
- You should define a range of command numbers to represent the font menu items.
-
- #define cFirstFontCommand cMyLastCommand + 1
- // Subsequent command numbers used by fonts
-
- void AddFontsToMenu(Environment* ev, FW_CPullDownMenu* menu)
- {
- short count = 0;
- FW_CFontIterator fontIter;
- FW_CString fontName;
- ODCommandID commandID = cFirstFontCommand;
- for (fontName = fontIter.First(); fontIter.IsNotComplete(); fontName = fontIter.Next())
- {
- menu->AppendTextItem(ev, fontName, commandID+count);
- count++;
- }
- gFontCount = count;
- }
-
- FW_Boolean CMyEditView::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- //-- Enable all items in the Font menu
- ODCommandID c = cFirstFontCommand;
- for (short i=0; i < gFontCount; c++, i++)
- menuBar->EnableAndCheckCommand(ev, c, true, false);
-
- //-- Put a check in front of the current font
- c = GetCurrentFontCmd(ev, menuBar);
- if (c != 0)
- menuBar->CheckCommand(ev, c, true);
- }
-
- return FW_CEditView::DoAdjustMenus(ev, menuBar, hasMenuFocus, isRoot);
- }
-
- ODCommandID CMyEditView::GetCurrentFontCmd(Environment* ev, FW_CMenuBar* menuBar)
- {
- ODCommandID result = 0;
-
- ODCommandID c = cFirstFontCommand;
- FW_CString fontName;
- for (short i=0; i < gFontCount; i++, c++)
- {
- menuBar->GetItemString(ev, c, fontName);
- if (fontName == fFontName)
- {
- result = c;
- break;
- }
- }
-
- return result; // could be 0
- }
-
- FW_Boolean CMyEditView::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean menuHandled = true;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- if (cFirstFontCommand <= id && id < cFirstFontCommand+gFontCount)
- {
- this->CommandToString(ev, id, fFontName);
- this->DoSetFont(ev);
- return menuHandled;
- }
- ...
- }
-
- Mary Boetcher
- ODF Person
-